/* mobx 的基本使用 */
import React, { createContext, useContext } from 'react';
import mobxStore from './mobxStore';

/* 全局 context */
export const MyContext = createContext(mobxStore); // <typeof mobxStore>
/* 自定义 hook */
export const useMobxStore = () => {
  const store = useContext(MyContext);
  if (!store) throw Error('no Mobx store');
  return store;
};

const MyProvider = ({ children, props }) => {
  // : React.FC
  console.log('mobxStore index.jsx', 111, props);
  return <MyContext.Provider value={mobxStore}>{children}</MyContext.Provider>;
};

export default MyProvider;
